package com.company.control;

import com.company.bean.UserInfoBean;
import com.company.util.MyUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "MessageTest1Servlet", value = "/MessageTest1Servlet")
public class MessageTest1Servlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //设置编码值
        request.setCharacterEncoding("utf-8");

        //1.获取表单数据
        UserInfoBean userInfoBean = MyUtils.getNewInstance(UserInfoBean.class);
        userInfoBean.setUsername(request.getParameter("username"));
        userInfoBean.setUserpsw(request.getParameter("userpsw"));
        userInfoBean.setUsersex(request.getParameter("usersex"));
        userInfoBean.setUsersign(request.getParameter("usersign"));
        userInfoBean.setUserother(request.getParameter("userother"));

        //2.调用model层进行业务逻辑查询处理
        //跳转之前，需要将显示在成功页面的数据进行session缓存
        request.getSession().setAttribute("userInfoBean", userInfoBean);

        //3.显示查询结果页面
        request.getRequestDispatcher("WEB-INF/views/messageTest1.jsp")
                .forward(request, response);


    }

}
